<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>一点知识系统</title><!-- 知识课件 -->
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3"/>
<meta http-equiv="description" content="this is my page"/>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<script type="text/javascript" src="../../head.js"></script>
<script type="text/javascript" src="../../script/ajaxfileupload.js"></script>
</head>
<body>

<div id="tools" class="datagrid-toolbar">
		<a onclick="add();"  class="easyui-linkbutton" iconCls="icon-add" plain="true">新增</a>
		<a onclick="edit();" class="easyui-linkbutton" iconCls="icon-edit" plain="true">编辑</a>
		<a onclick="del();"  class="easyui-linkbutton" iconCls="icon-cancel" plain="true">删除</a>
</div>

 <form id="jvForm" action="" enctype="multipart/form-data" method="post">
	<div id="search" class="datagrid-toolbar">
		<table>
			    <tr>
					<td align="right">添加时间：</td>
				    <td align="left">
					<input name="startDate" id="startDate" class="Wdate" style="width:100px;" 
						onFocus="WdatePicker({dateFmt:'yyyy-MM-dd',maxDate:'#F{$dp.$D(\'endDate\')}'})" />-
					<input name="endDate" id="endDate" class="Wdate" style="width:100px;" 
						onFocus="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'#F{$dp.$D(\'startDate\')}'})" />
				    </td>
				    
					<td align="right">课件名称：</td>
					<td align="left">
						<input name="coursewarename" id="coursewarename" />
					</td>
					
				</tr>
				<tr>
					<td align="right" class="collegetype">课件类型：</td>
					<td align="left"  class="collegetype">
						<select id="collegetype" name="typeid"><!-- 说明：下拉和id没有关系只和name有关，会吧选择的列表的某一个id给name进行获取和赋值 -->
							<option value="-1">--请选择--</option>
						</select>
					</td>
					
					<td align="right">&nbsp;&nbsp;&nbsp;&nbsp;</td>
					<td><a class="easyui-linkbutton" iconCls="icon-search"
						plain="true" onclick="query();" style="border: 1px solid #99CCFF;">确定</a> 
					<a class="easyui-linkbutton" iconCls="icon-recycle"
						plain="true" onclick="requery();" style="border: 1px solid #99CCFF;">重置</a> 
					</td>
			   </tr>
		</table>
	</div>
 </form>
<table id="list_data"></table>
<br />

<div id="tools" class="datagrid-toolbar" style="text-align: center;">
	<a onclick='addChildKeShi();' class='popup_btn'>添加子课时</a>
</div>

<div id="opWindow" class="easyui-window" title="" data-options="closed:true,draggable:false,modal:true,iconCls:'icon-manager',minimizable:false,maximizable:false" style="width:1000px;height:500px;">
			<iframe id="windowIframe" src="" scrolling="auto" frameborder="0"
			style="width: 100%; height: 100%;" ></iframe>
</div>
</body>
</html>
<script>
	$('#list_data').datagrid({
		url:contextPath+"/system/queryAllCourseWareSearch?i="+new Date().getTime(),
		fitColumns:false,
		singleSelect:false,
		method:'POST',
		rownumbers:true,
		pagination:true,
		striped:true,
		onLoadSuccess:onLoadScroll,
		columns:[[
			{field:'id',checkbox:true,sortable:true},
			{field:'coursewarename',title:'课件名称',width:150,sortable:true,align:'center',formatter:contentRenderer},
			{field:'collegeimage',title:'图片资源',width:150,sortable:true,align:'center',formatter:logoRenderer},
			{field:'coursewarenum',title:'课时',width:100,sortable:true,align:'center',formatter:contentRenderer},
			{field:'coursewaretimelong',title:'时长',width:100,sortable:true,align:'center',formatter:contentRenderer},
			{field:'coursewareaddtime',title:'添加时间',width:180,sortable:true,align:'center',formatter:contentRenderer},
			{field:'remark',title:'备注信息',width:150,sortable:true,align:'center',formatter:contentRenderer},
			/* {field:'op',title:'',width:0} */
		]]
	});
	
	//显示选择的类型
	selectType();
	
	//选择知识课件
	function selectType(){
		$("#collegetype").empty();
		$.post(contextPath+"/system/queryAllCollegetypeBytype?collegetypecode=1",
		  {'dataCode':"collegetype",'depth':2},function(data){
		     $("#collegetype").append("<option value='-1'>--请选择--</option>");
		     if(data!=null && data.length>0){
		    	 for(var i=0;i<data.length;i++){
		    		 $("#collegetype").append("<option value='"+data[i]['id']+"'>"+data[i]['collegename']+"</option>"); 
		    	 }
		     }
		 });
	}
	
	//图片列显示
	function logoRenderer(value,row,index){
		if(value!=null && value!=""){
			return /* value+ */"<a style='color:blue;' href='javascript:showImg(\""+row.coursewareimageid+"\");'>查看</a>"
		}else{
			return "";
		}
	}
	
	function showImg(logo){
		parent.messager_alert("查看图片资源","<img src='"+contextPath+"/system/affix/"+logo
				+"/showImage'style='width:300px;height:200px;' onerror=\"this.src='"+contextPath
				+"/manager/images/default.jpg'\"/>","info");
	}
	
	
	function contentRenderer(value,row,index){
		if(value!=null){
			if(value.length>10){
				return "<span title='"+value+"'>"+value+"</span>";
			}
			return value;
		}
		return "";
	}
	
	//查询
	function query(){
		searchGo(contextPath+"/system/queryAllCourseWareSearch?i="+new Date().getTime(),"#search","#list_data");
	}
	//清空
	function requery(){
		clearGo(contextPath+"/system/queryAllCourseWareSearch?i="+new Date().getTime(),"#search","#list_data");
	}
	
	//添加信息
	function add(){
		openWindow(contextPath+"/manager/basic/main/main_courseware_add.html");
	}
	
	
	
	//修改的方法
	function edit(){
		var id = getId('#list_tree','tree');//获取选中的行
		if(id == ""){
			return;
		}
		/* openWindow(contextPath+"/manager/basic/main/main_subclasstime_add.html?id="+id); */
	}
	
	// 添加子课时
	function addChildKeShi(){
		var ids = getIds('#list_data','data');//获取选中的行
		if(ids == ""){
			return;
		}
		openWindow(contextPath+"/manager/basic/main/main_subclasstime_list.html?id="+ids);
	}
	
	
	//行的双击事件
	function dbClick(rowData){
		/* openWindow(contextPath+"/manager/system/sysMenu/sysMenu_edit.html?id="+rowData['id']); */
	}
	//删除事件
	function del(){
		var ids = getId('#list_tree','tree');//获取选中的行ids
		if(ids == ""){
			return;
		}
		if(ids==1){
			$.messager.alert("提示","此节点不能删除!",'info');
			return;
		}
		$.messager.confirm('提示','确定要删除吗?',function(r){
			if(r){
				$.ajax({
					type : 'POST',
					url : contextPath+'/system/delSysMenu',
					data : {'ids':ids},
					dataType : "json",
					success : function(data){
						var res =data;
						if(res['flag'] == "success"){
							$.messager.alert("提示","操作成功!",'info',function(rt){
								query();
							});
						}
					},
					error:function(response){
						$.messager.alert("提示","出错了，请联系管理员!",'error',function(rt){
							$.messager.alert("提示",response.responseText,'error');
						});
					}
				});
			}
		});
	}
	
</script>